
<style lang="scss" scoped>
.scroll {
  height: 100%;
  overflow: hidden;
}

.container {
  position: fixed;
  width: 100%;
  top: 60px;
  bottom: 0;
  background: #f0f0f0;
  border-top: 1px solid #e5e5e5;
  ul {
    width: 100%;
    height: auto;
    li.item {
      width: 100%;
      min-height: 70px;
      background: #fff;
      img {
        width: 84px;
        height: 84px;
        display: inline-block;
        margin-left: 10px;
      }
    }
  }
  .pro-info {
    margin-left: 10px;
  }
  .item-count {
    width: 100%;
    height: 25px;
    position: relative;
    margin-top: 5px;
  }

  .hidden {
    display: none;
  }

  .item-count > span {
    font-size: 16px;
    color: rgba(255, 155, 175, 1);
  }

  .item-hand {
    position: relative;
  }

  .item-hand__bg {
    background: rgba(255, 137, 156, 1);
    opacity: 0.2;
    width: 75px;
    height: 20px;
    z-index: 10;
    border-radius: 10px;
  }

  .item-hand__it {
    position: absolute;
    right: 0px;
    height: 20px;
    width: 71px;
    top: 0px;
  }

  .item-hand__it i {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
  }

  .item-hand__it i.add {
    background: url("/static/ethel_img/shop/but_plus_usable@2x.png") center
      center no-repeat;
    background-size: 100% 100%;
    vertical-align: middle;
  }

  .item-hand__it input {
    outline: none;
    border: none;
    width: 100%;
    height: 100%;
    font-size: 12px;
    text-align: center;
  }

  .item-hand__it i.dect {
    background: url("/static/ethel_img/shop/but_subtract_usable@2x.png") center
      center no-repeat;
    background-size: 100% 100%;
    vertical-align: middle;
    margin-left: -4px;
  }
}
nav {
  height: 42px;
  background: #fff;
  div {
    font-size: 14px;
    text-align: center;
    height: 42px;
    line-height: 42px;
    color: #999;
  }
}
.order-con {
  position: relative;
  border-top: 1px solid rgba(238,238,238,1);;
  .item {
    padding: 6px 15px 0px;
    background: #fff;
    .item-info {
      width: 100%;
      height: 37px;
      line-height: 37px;
      color: #333;
      font-size: 14px;
      position: relative;
      span {
        font-weight: bold;
        font-size: 18px;
        position: absolute;
        right: 0px;
      }
    }
    .item-time {
      width: 100%;
      height: auto;
      font-size: 12px;
      color:rgba(160,154,155,1);
      padding-bottom: 20px;
      border-bottom: 1px solid rgba(238,238,238,1);
    }
  }
  .number > span.integral::before {
    content: "";
    width: 20px;
    height: 20px;
    display: inline-block;
    background: url("/static/ethel_img/order_icon_integral.png") center center
      no-repeat;
    background-size: 100% 100%;
    vertical-align: middle;
  }
}
.notMore {
  width: 100%;
  height: 100%;
  padding-top: 70px;
  span {
    font-size: 13px;
    color: rgba(160, 154, 155, 1);
    margin-top: 15px;
  }
  img {
    width: 140px;
    height: 85px;
    display: block;
  }
  
}
.spanActive {
    color: #FF899C !important
  }
</style>

<template>
  <div class="withdrawal">
    <ComHeader title="明细" leftArrow="true"/>
    <div class="container">
      <nav class="flex-display">
        <div
          class="flex-num-one"
          v-for="(item, index) in navList"
          :key="index"
          :class="{'select_border__b':item.select}"
          @click="fnSelectStatus(item)"
        >{{item.name}}</div>
      </nav>
      <scroll
        class="scroll"
        :data="drawalList"
        :pullup="isPullup"
        @scrollToEnd="searchMore"
        v-if="drawalList && drawalList.length"
        ref="suggest"
      >
        <ul class="order-con">
          <li class="item" v-for="(item, index) in drawalList" :key="index">
            <div class="item-info">
              {{item.fee_type}}{{item.yj_type}}
              <span class="spanActive" v-if="item.yj_type == '收入'">+{{item.yongjin}}</span>
              <span v-else>-{{item.yongjin}}</span>
            </div>
            <div class="item-time">{{item.createtime}}</div>
          </li>
        </ul>
      </scroll>
      <div
        class="notMore flex-display flex-display-column flex-center-align"
        v-if="isLoading && !drawalList.length"
      >
        <img src="/static/ethel_img/shopping_img_em.png">
        <span>明细空空如也！！</span>
      </div>
    </div>
  </div>
</template>
<script>
import api from "@/fetch/api";
import ComHeader from "@/common/ComHeader";
import Scroll from "@/base/scroll/scroll";
import Loading from "@/base/loading/loading";
import axios from "axios";
import { Toast, MessageBox, Indicator } from "mint-ui";
export default {
  data() {
    return {
      isHasMore: true, // 是否需要上拉加载
      drawalList: [], // 列表数据
      isPullup: true, // 是否需要监听下拉加载
      status: "come", // 订单状态
      isNext: "", // 是否有下一页
      isLoading: false,
      navList: [
        { name: "收入明细", select: true, status: "come" },
        { name: "支出明细", select: false, status: 'out' },
      ]
    };
  },
  created() {
    this.userInfo = this.getlocalStorage(this.companyUnique);
    // 获取数据
    this.getOrderList();
  },
  methods: {

    /**
     * @desc 选择订单类型
     * @param {Object} _item 订单类型对象
     */
    fnSelectStatus(_item) {
      this.navList.forEach(item => {
        item.select = false;
      });
      _item.select = true;
      this.drawalList = [];
      this.status = _item.status;
      this.isNext = "";
      this.getOrderList();
    },
    getOrderList() {
      Indicator.open({
        text: "加载中...",
        spinnerType: "fading-circle"
      });
      let params = {
        type: this.status,
        uid: this.userInfo.id 
      };
      api
        .getBalanceRecord(params, this.isNext ? this.isNext : "")
        .catch(res => {
          console.log(res);
          console.log('请求数据')
          Indicator.close();
          this.isLoading = true;
          if (res.status == 200) {
            this.isNext = res.data.next;
            if (res.data.results && res.data.results.length) {
              this.drawalList = [...this.drawalList, ...res.data.results];
            }
          }
        })
        .then(err => {
          Indicator.close();
        });
    },
    /**
     * @desc 是否需要下拉加载
     */
    searchMore() {
      if (this.isNext) {
        this.getOrderList();
        return;
      }
      Toast({
        message: "我是有底线的",
        position: "middle",
        duration: 2000
      });
    }
  },
  components: {
    Scroll,
    ComHeader,
    Loading,
    Toast,
    MessageBox,
    Indicator
  }
};
</script>



